<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>深拷贝测试</title>
  <script src="../../src/object/clone.js"></script>
</head>

<body>
  <script>
    const obj = {
      a: 1,
      b: ['e', 'f', 'g'],
      c: { h: 20 },
      //JSON不能克隆方法
      d:function(){}
    };
    // 4.循环效率问题优化
    obj.b.push(obj.c)
    obj.c.j = obj.b
    console.log(obj)
    const result = deepClone4(obj)
    console.log(result)


    //3.解决循环引用问题
    // obj.b.push(obj.c)
    // obj.c.j = obj.b
    // console.log(obj)
    // const result = deepClone3(obj)
    // console.log(result)


    //2.递归拷贝
    // const result = deepClone2(obj)
    // console.log(obj)
    // console.log(result)


    // 1.json
    // 循环引用
    /* obj.b.push(obj.c)
    obj.c.j = obj.b */
    // const result = deepClone1(obj);
    // result.c.h = 20000
    // console.log(obj);
    // console.log(result);
  </script>
</body>

</html>